home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor2 / probdist.src < prev    next >
Text File  |  1992-01-11  |  8KB  |  238 lines

  1. %%HP: T(3)A(D)F(.);
  2. @ PROBDIST by Luca Radice
  3.     DIR
  4.       BINO
  5.         DIR
  6.         @ Contents:
  7.         @ Bino: Equation of binomial distribution
  8.         @       Set value of 'n' and 'p' or use solvr.
  9.         @ P: Computes the binomial value for a given k value
  10.         @    using the values of 'n' 'p' stored into the variables.
  11.         @ \Gm: (mu) Calculate the mean of distribution.
  12.         @ \Gs2: (Sigma^2) Standard variation.
  13.         @ G: equation of momentum generator.
  14.         @ RANGE: Computes the cumulative value between
  15.         @        a and b.
  16.           Bino 'n!/(k!*(n-k)!)*p^k*(1-p)^(n-k)'
  17.           P
  18.             \<< \-> k 'n!/(k!*(n-k)!)*p^k*(1-p)^(n-k)' \>>
  19.           \Gm
  20.             \<< 'n*p' \>>
  21.           \Gs2
  22.             \<< 'n*p*(1-p)' \>>
  23.           n 15
  24.           p .12
  25.           G '(1-p+p*e^t)^n'
  26.           RANGE
  27.             \<< \-> a b
  28.               \<< 0 a b FOR T T P + NEXT \>>
  29.             \>>
  30.         END
  31.       POIS
  32.         DIR
  33.         @ Contents:
  34.         @ POIS: Equation of Poisson distribution
  35.         @       Set value of 'np'.
  36.         @ P: Computes the equation value for a given k value
  37.         @    using the value 'np' stored into the variables.
  38.         @ \Gm: (mu) Calculate the mean of distribution.
  39.         @ \Gs2: (Sigma^2) Standard variation.
  40.         @ G: equation of momentum generator.
  41.         @ RANGE: Computes the cumulative value between
  42.         @        a and b.
  43.           POIS '\Gl^k/k!*e^-\Gl'
  44.           P
  45.             \<< \-> k '\Gl^k/k!*e^-\Gl' \->NUM \>>
  46.           \Gm np
  47.           \Gs2 np
  48.           np 3.297
  49.           \Gl np
  50.           G 'e^\Gl(e^t-1)'
  51.           RANGE
  52.             \<< \-> a b
  53.               \<< 0 a b FOR T T P + NEXT \>>
  54.             \>>
  55.         END
  56.       GAUS
  57.         DIR
  58.         @ Contents:
  59.         @ GAUS: Equation of Gauss (and Normal) distribution
  60.         @       Set value of '\Gm'(mean) and '\Gs' (sigma).
  61.         @ F: Computes the equation value for a given X value
  62.         @    using the values of mean and sigma stored into the variables.
  63.         @ P: Computes the area of the upper queue of distribution
  64.         @    between a and +infinite.
  65.         @ G: equation of momentum generator.
  66.         @ P\->X: Computes the X value for a given upper queue area R;
  67.         @        (reverse the equation: ONLY for Standard NORMAL).
  68.         @ RANGE: Computes the area of distribution between
  69.         @        a and b.
  70.           GAUS '1/(\v/(2*\pi)*\Gs)*e^(-(X-\Gm)^2/(2*\Gs^2))'
  71.           G 'e^(\Gm*t)*e^(1/2*\Gs^2*t^2)'
  72.           F
  73.             \<< 'X' STO GAUS \->NUM \>>
  74.           P
  75.             \<< \-> a
  76.               \<< \Gm \Gs 2 ^ a UTPN \>>
  77.             \>>
  78.           \Gm 0
  79.           \Gs 1
  80.           X 5
  81.           P\->X
  82.             \<<
  83.               .000001 \-> H R
  84.               \<< -6 'A' STO 6 'B' STO
  85.                 DO B A - 2 / A + 'M' STO M
  86.                   IF 0 1 M UTPN H \>=
  87.                   THEN 'A' STO
  88.                   ELSE 'B' STO
  89.                   END
  90.                 UNTIL 0 1 A UTPN H - ABS R \<=
  91.                 END
  92.               \>> A { A B M } PURGE
  93.             \>>
  94.           RANGE
  95.             \<< \-> a b
  96.               \<< a P b P - \>>
  97.             \>>
  98.         END
  99.       CHI2
  100.         DIR
  101.         @ Contents:
  102.         @ CHI2: Equation of Chi^2 distribution
  103.         @       Set value of 'v' (freedom degrees).
  104.         @ F: Computes the equation value for a given ki2 value
  105.         @    using the value of 'v' stored into the variable.
  106.         @ P: Computes the area of the upper queue of distribution
  107.         @    between a and +infinite.
  108.         @ G: equation of momentum generator.
  109.         @ CHI\->X: Computes the X value for a given upper queue area R;
  110.         @          (reverse the equation).
  111.         @ \Gs2: (Sigma^2) Standard variation.
  112.           CHI2 '1/(2^(v/2)*(v/2)!)*e^(-ki2/2)*ki2^(v/2-1)'
  113.           F
  114.             \<< 'ki2' STO CHI2 \->NUM \>>
  115.           P
  116.             \<< \-> a
  117.               \<< v a UTPC \>>
  118.             \>>
  119.           v 2
  120.           \Gs2
  121.             \<< '2*v' \->NUM \>>
  122.           ki2 .920044414629
  123.           CHI\->X
  124.             \<<
  125.               .0000001 \-> H R
  126.               \<< 0 'A' STO 200 'B' STO
  127.                 DO B A - 2 / A + 'M' STO M
  128.                   IF v M UTPC H \>=
  129.                   THEN 'A' STO
  130.                   ELSE 'B' STO
  131.                   END
  132.                 UNTIL v A UTPC H - ABS R \<=
  133.                 END
  134.               \>> A { A B M } PURGE
  135.             \>>
  136.           G '1/(1-2*t)^(v/2)'
  137.         END
  138.       GAMM
  139.         DIR
  140.         @ Contents:
  141.         @ GAMM: Equation of Gamma distribution
  142.         @       Set value of '\Gr' and 'k' (freedom degrees).
  143.         @ F: Computes the equation value for a given X value
  144.         @    using the values of '\Gr' and 'k' stored into the variables.
  145.         @ P: Computes the area of distribution
  146.         @    between a and b.
  147.         @ \Gm: (mu) Calculate the mean of distribution.
  148.         @ \Gs2: (Sigma^2) Standard variation.
  149.           GAMM '1/k!*\Gr^k*X^(k-1)*e^(-\Gr*X)'
  150.           F
  151.             \<< 'X' STO GAMM \->NUM \>>
  152.           P
  153.             \<< \-> a b
  154.               \<< a b GAMM 'X' \.S \->NUM 'IERR' PURGE \>>
  155.             \>>
  156.           \Gm
  157.             \<< 'k/\Gr' \->NUM \>>
  158.           \Gs2
  159.             \<< 'k/\Gr^ 2' \->NUM \>>
  160.           k 1
  161.           \Gr 2
  162.           X 1
  163.         END
  164.       STUD
  165.         DIR
  166.         @ Contents:
  167.         @ STUD: Equation of Student (t) distribution
  168.         @       Set value of 'v' (freedom degrees).
  169.         @ F: Computes the equation value for a given t value
  170.         @    using the value of 'v' stored into the variable.
  171.         @ P: Computes the area of the upper queue of distribution
  172.         @    between a and +infinite.
  173.         @ \Gm: (mu) Calculate the mean of distribution.
  174.         @ \Gs2: (Sigma^2) Standard variation.
  175.           STUD '((v+1)/2)!/(\v/(\pi*v)*(v/2)!)*(1/(1+t^2/v)^((v+1)/2))'
  176.           F
  177.             \<< 't' STO STUD \->NUM \>>
  178.           P
  179.             \<< \-> a
  180.               \<< v a UTPT \>>
  181.             \>>
  182.           \Gm 0
  183.           \Gs2
  184.             \<< 'v/(v-2)' \->NUM \>>
  185.           v 4
  186.           t 8
  187.         END
  188.       FISH
  189.         DIR
  190.         @ Contents:
  191.         @ FISH: Equation of Fisher (f) distribution
  192.         @       Set value of 'v' and '\Gl' (freedom degrees).
  193.         @ F: Computes the equation value for a given x value
  194.         @    using the value of 'v' stored into the variable.
  195.         @ P: Computes the area of the upper queue of distribution
  196.         @    between a and +infinite.
  197.         @ \Gm: (mu) Calculate the mean of distribution.
  198.         @ \Gs2: (Sigma^2) Standard variation.
  199.           FISH '\Gl^(\Gl/2)*v^(v/2)*((\Gl+v)/2)!/((\Gl/2)!*(v/2)!)*
  200.                 (x^((\Gl-2)/2)/(\Gl*x+v)^((\Gl+v)/2))'
  201.           F
  202.             \<< 'x' STO FISH \->NUM \>>
  203.           P
  204.             \<< \-> a
  205.               \<< \Gl v a UTPF \>>
  206.             \>>
  207.           \Gm
  208.             \<< 'v/(v -2)' \->NUM \>>
  209.           \Gs2
  210.             \<< '2*v^2*(\Gl+v-2)/(\Gl*(v-2)^2*(v-4))' \->NUM \>>
  211.           \Gl 1
  212.           v 5
  213.           x 4
  214.         END
  215.       ESPON
  216.         DIR
  217.         @ Contents:
  218.         @ ESPON: Equation of Esponential distribution
  219.         @        Set value of '\Gm' (mean).
  220.         @ F: Computes the equation value for a given X value
  221.         @    using the value of '\Gm' stored into the variable.
  222.         @ P: Computes the area of the upper queue of distribution
  223.         @    between a and +infinite.
  224.         @ \Gm: (mu) mean of distribution.
  225.           ESPON '1/\Gm*e^-(X/\Gm)'
  226.           F
  227.             \<< 'X' STO ESPON \->NUM \>>
  228.           P
  229.             \<< \-> a
  230.               \<< a .000000002 \Gm * LN \Gm
  231.                 NEG * a + ESPON 'X' \.S \->NUM
  232.               \>>
  233.             \>>
  234.           \Gm 5
  235.           X 2
  236.         END
  237.     END
  238.